package com.ruibang.glass.sale.controller;

import com.ruibang.glass.sale.domain.req.GSaleContractManReq;
import com.ruibang.glass.sale.domain.req.GSaleOrderReq;
import com.ruibang.glass.sale.domain.req.SaleBalanceReq;
import com.ruibang.glass.sale.domain.req.SaleshippingApplicationReq;
import com.ruibang.glass.sale.entity.SaleBalanceGoods;
import com.ruibang.glass.sale.service.GSaleContractManagementService;
import com.ruibang.glass.sale.service.GSaleOrderManagementService;
import com.ruibang.glass.sale.service.SaleBalanceGoodsService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@Api(tags = "结算单")
@RestController
@RequestMapping("/api/glass/sale/balance/good")
public class SaleBalanceGoodController {
    @Autowired
    private SaleBalanceGoodsService saleBalanceGoodsService;

    @PostMapping("list")
    @ApiOperation(value = "结算单列表", response = ResultBody.class)
    public ResultBody list(@RequestBody SaleBalanceReq balanceReq) {
        return ResultBody.success(saleBalanceGoodsService.getPage(balanceReq));
    }

    @PostMapping("addSaleBalanceGoods")
    @ApiOperation(value = "新增", response = ResultBody.class)
    public ResultBody addSaleBalanceGoods(@RequestBody SaleBalanceGoods saleBalanceGoods) {
        saleBalanceGoodsService.addSaleBalanceGoods(saleBalanceGoods);
        return ResultBody.success();
    }

    @PostMapping("addSaleBalanceCollection")
    @ApiOperation(value = "新增收款单", response = ResultBody.class)
    public ResultBody addSaleBalanceCollection(@RequestBody SaleBalanceGoods saleBalanceGoods) {
        saleBalanceGoodsService.addSaleBalanceCollection(saleBalanceGoods);
        return ResultBody.success();
    }

    @PostMapping("addSaleBalanceInvoice")
    @ApiOperation(value = "新增发票", response = ResultBody.class)
    public ResultBody addSaleBalanceInvoice(@RequestBody SaleBalanceGoods saleBalanceGoods) {
        saleBalanceGoodsService.addSaleBalanceInvoice(saleBalanceGoods);
        return ResultBody.success();
    }

    @GetMapping("getOne/{id}")
    @ApiOperation(value = "详情查看", response = ResultBody.class)
    public ResultBody addSaleBalanceInvoice(@PathVariable("id")String id) {
        return ResultBody.success(saleBalanceGoodsService.getSaleBalanceGoodsById(id));
    }

    @GetMapping("removeById/{id}")
    @ApiOperation(value = "详情查看", response = ResultBody.class)
    public ResultBody removeById(@PathVariable("id")String id) {
        return ResultBody.success(saleBalanceGoodsService.removeById(id));
    }

}
